package com.lagou.xml05;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @Author wsl
 * @Date 2021/8/24 22:35
 * @Project_Name mysql
 */
public class TestJDBCUtils {

    public static void main(String[] args) {
        Connection con = null;
        Statement statement = null;
        ResultSet resultSet = null;

        try {
            //1.获取连接
            con = JDBCUtils.getConnection();

            //2.获取statement 来执行SQL
            statement = con.createStatement();
            String sql = "select * from employee";

            //3.处理结果集
            resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                String ename = resultSet.getString("ename");
                System.out.println(ename);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.close(con,statement,resultSet);
        }
    }
}
